<?php
/**
 * SummerCamps Model for SummerCamps World Component
 * 
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_2
 * @license    GNU/GPL
 */
 
// No direct access
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.application.component.model' );
 
/**
 * SummerCamps Model
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
//Naming convention for a model:
// [Component Name]["Model"][Model Name]
//-[SummerCamps][Model][SummerCamps]
//The Controller will automatically load a model into the view with the same name. 
class SummerCampsModelSummerCamps extends JModel
{
    /**
     * Camps data array
     *
     * @var array
     */
    var $_data;
    var $_iddata;
 
    /**
     * Returns the query
     * return the list of camps from the database
     * @return string The query to be used to retrieve the rows from the database
     */
    function _buildQuery()
    {
        $query = ' SELECT * '
            . ' FROM #__summercamps WHERE Approved=1';
        return $query;
    }
 
    
    /**
     * METHODS THAT START WITH 'get' CAN BE ACCESSED USING THE get() METHOD
     * OF THE JView CLASS. 
     * 
     * EX: $items =& &this->get('Data');
     * 
     * Retrieves the camp data
     * @return array Array of objects containing the data from the database
     */
    function getData()
    {
        // Lets load the data if it doesn't already exist
        if (empty( $this->_data ))
        {
            $query = $this->_buildQuery();
            $this->_data = $this->_getList( $query );
        }
 
        return $this->_data;
    }
    

}